{layout name="layout" /}

<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i>
    <a href="{:url('admin/index/index')}"> 首页</a>
    <span class="c-gray en">&gt;</span>
    <a href="{:url('admin/data_content/index')}">数据内容管理</a>
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);"
        title="刷新">
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>

<div class="Hui-article">
    <article class="cl pd-20" style="min-width: 900px;">
        <div class="cl pd-5 bg-1 bk-gray mt-20">
            <span class="l">
                <a href="javascript:;" onclick="del_all()" class="btn btn-danger radius">
					<i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
				<a class="btn btn-primary radius" href="{empty name='tablename'}javascript:void(0);{else/}{:url('addOrEdit', 'tablename='.$tablename)}{/empty}">
					<i class="Hui-iconfont">&#xe600;</i> 添加数据</a>
            </span>
            <span class="select-box inline ml-50">
                <select name="tablename" id="sel_option" class="select" style="width: 600px;">
                    <option value="" {empty name="tablename"}selected{/empty}>请选择数据表</option>
                    {foreach $categories as $value}
                        <option value="{$value.tablename}" {notempty name="tablename"}{eq name='tablename' value="$value.tablename"}selected{/eq}{/notempty}>{$value.name}{$value.tablename ?? '('.$value.tablename.')'}</option>
                        {notempty name="value.child"}
                            {foreach $value.child as $val}
                            <option value="{$val.tablename}" {notempty name="tablename"}{eq name='tablename' value="$val.tablename"}selected{/eq}{/notempty}>--{$val.name}{$val.tablename ?? '('.$val.tablename.')'}</option>
                            {notempty name="val.child"}
                                {foreach $val.child as $vo}
                                <option value="{$vo.tablename}" {notempty name="tablename"}{eq name='tablename' value="$vo.tablename"}selected{/eq}{/notempty}>&nbsp;&nbsp;└ --{$vo.name}({$vo.tablename ?? '('.$vo.tablename.')'})</option>
                                {/foreach} 
                            {/notempty} 
                            {/foreach} 
                        {/notempty} 
                    {/foreach}
                </select>
            </span>
            <span class="r">共有数据：<strong id="total">{notempty name="data"}{$data->total()}{else/}0{/notempty}</strong> 条</span>
        </div>
        <div id="edatalist">
            <table class="table table-border table-bordered table-bg">
                <thead>
                    <tr class="text-c">
                        <th width="25px;">
                            <input type="checkbox" name="" value="">
                        </th>
                        <th width="80px;">ID</th>
                        <th style="min-width: 200px;">标题</th>
                        <th width="160px;">发布者</th>
                        <th width="180px;">发布时间</th>
                        <th width="140px;">点击量</th>
                        <th width="200px;">操作</th>
                    </tr>
                </thead>
                <tbody>
                    {empty name="tablename"}
                    <tr class="text-c va-m" style="height:80px;">
                        <td colspan="7">
                            请选择数据表
                        </td>
                    </tr>
                    {else/}
                        {foreach $data as $val}
                        <tr class="text-c va-m">
                            <td>
                                <input type="checkbox" value="{$val.id}" name="checkbox[]">
                            </td>
                            <td>{$val.id}</td>
                            <td class="text-l">
                                <a href="javascript:void(0);" style="text-decoration:none" title="浏览">{$val.title}</a>
                            </td>
                            <td>{$val.username}</td>
                            <td>{$val.create_time|date="Y-m-d H:i:s", ###}</td>
                            <td>{$val.clicks}</td>
                            <td class="td-manage">
                                <a href="{:url('addOrEdit', ['id'=>$val.id,'tablename'=>$tablename])}" title="编辑" style="text-decoration:none" class="ml-10">
                                    <i class="Hui-iconfont">&#xe6df;</i>
                                </a>
                                <a href="javascript:;" title="删除" style="text-decoration:none" class="ml-10" onClick="del(this,'{$val.id}')">
                                    <i class="Hui-iconfont">&#xe6e2;</i>
                                </a>
                            </td>
                        </tr>
                        {/foreach}
                    {/empty}
                </tbody>
            </table>
        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-20 ">
            <span class="r">{notempty name="data"}{$data->render()}{/notempty}</span>
        </div>
    </article>
</div>
<script>
    $("#sel_option").change(function(){
        var tablename = $("#sel_option").val();
        console.log(tablename);
        window.location.href='/admin/data_content/index.html?tablename='+tablename;
    })
</script>